//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2024 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto-codegenerator.
// DO NOT EDIT.

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
@_exported import SotoCore

/// Service object for interacting with AWS ObservabilityAdmin service.
///
///  Amazon CloudWatch Obsersavability Admin to control temletry config for your AWS Organization or account. Telemetry config conﬁg to discover and understand the state of telemetry conﬁguration for your AWS resources from a central view in the CloudWatch console. Telemetry conﬁg simpliﬁes the process of auditing your telemetry collection conﬁgurations across multiple resource types across your AWS Organization or account.  For more information, see Auditing CloudWatch telemetry conﬁgurations in the CloudWatch User Guide. For information on the permissions you need to use this API, see Identity and access management for Amazon CloudWatch in the CloudWatch User Guide.
public struct ObservabilityAdmin: AWSService {
    // MARK: Member variables

    /// Client used for communication with AWS
    public let client: AWSClient
    /// Service configuration
    public let config: AWSServiceConfig

    // MARK: Initialization

    /// Initialize the ObservabilityAdmin client
    /// - parameters:
    ///     - client: AWSClient used to process requests
    ///     - region: Region of server you want to communicate with. This will override the partition parameter.
    ///     - partition: AWS partition where service resides, standard (.aws), china (.awscn), government (.awsusgov).
    ///     - endpoint: Custom endpoint URL to use instead of standard AWS servers
    ///     - middleware: Middleware chain used to edit requests before they are sent and responses before they are decoded 
    ///     - timeout: Timeout value for HTTP requests
    ///     - byteBufferAllocator: Allocator for ByteBuffers
    ///     - options: Service options
    public init(
        client: AWSClient,
        region: SotoCore.Region? = nil,
        partition: AWSPartition = .aws,
        endpoint: String? = nil,
        middleware: AWSMiddlewareProtocol? = nil,
        timeout: TimeAmount? = nil,
        byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator(),
        options: AWSServiceConfig.Options = []
    ) {
        self.client = client
        self.config = AWSServiceConfig(
            region: region,
            partition: region?.partition ?? partition,
            serviceName: "ObservabilityAdmin",
            serviceIdentifier: "observabilityadmin",
            serviceProtocol: .restjson,
            apiVersion: "2018-05-10",
            endpoint: endpoint,
            errorType: ObservabilityAdminErrorType.self,
            middleware: middleware,
            timeout: timeout,
            byteBufferAllocator: byteBufferAllocator,
            options: options
        )
    }





    // MARK: API Calls

    ///  Returns the current onboarding status of the telemetry config feature, including the status of the feature and reason the feature failed to start or stop.
    @Sendable
    @inlinable
    public func getTelemetryEvaluationStatus(logger: Logger = AWSClient.loggingDisabled) async throws -> GetTelemetryEvaluationStatusOutput {
        try await self.client.execute(
            operation: "GetTelemetryEvaluationStatus", 
            path: "/GetTelemetryEvaluationStatus", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            logger: logger
        )
    }

    ///  This returns the onboarding status of the telemetry configuration feature for the organization. It can only be called by a Management Account of an AWS Organization or an assigned Delegated Admin Account of AWS CloudWatch telemetry config.
    @Sendable
    @inlinable
    public func getTelemetryEvaluationStatusForOrganization(logger: Logger = AWSClient.loggingDisabled) async throws -> GetTelemetryEvaluationStatusForOrganizationOutput {
        try await self.client.execute(
            operation: "GetTelemetryEvaluationStatusForOrganization", 
            path: "/GetTelemetryEvaluationStatusForOrganization", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            logger: logger
        )
    }

    ///  Returns a list of telemetry configurations for AWS resources supported by telemetry config. For more information, see Auditing CloudWatch telemetry configurations.
    @Sendable
    @inlinable
    public func listResourceTelemetry(_ input: ListResourceTelemetryInput, logger: Logger = AWSClient.loggingDisabled) async throws -> ListResourceTelemetryOutput {
        try await self.client.execute(
            operation: "ListResourceTelemetry", 
            path: "/ListResourceTelemetry", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    ///  Returns a list of telemetry configurations for AWS resources supported by telemetry config. For more information, see Auditing CloudWatch telemetry configurations.
    ///
    /// Parameters:
    ///   - maxResults:  A number field used to limit the number of results within the returned list.
    ///   - nextToken:  The token for the next set of items to return. A previous call generates this token.
    ///   - resourceIdentifierPrefix:  A string used to filter resources which have a ResourceIdentifier starting with the ResourceIdentifierPrefix.
    ///   - resourceTags:  A key-value pair to filter resources based on tags associated with the resource. For more information about tags, see What are tags?
    ///   - resourceTypes:  A list of resource types used to filter resources supported by telemetry config. If this parameter is provided, the resources will be returned in the same order used in the request.
    ///   - telemetryConfigurationState:  A key-value pair to filter resources based on the telemetry type and the state of the telemetry configuration. The key is the telemetry type and the value is the state.
    ///   - logger: Logger use during operation
    @inlinable
    public func listResourceTelemetry(
        maxResults: Int? = nil,
        nextToken: String? = nil,
        resourceIdentifierPrefix: String? = nil,
        resourceTags: [String: String]? = nil,
        resourceTypes: [ResourceType]? = nil,
        telemetryConfigurationState: [TelemetryType: TelemetryState]? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> ListResourceTelemetryOutput {
        let input = ListResourceTelemetryInput(
            maxResults: maxResults, 
            nextToken: nextToken, 
            resourceIdentifierPrefix: resourceIdentifierPrefix, 
            resourceTags: resourceTags, 
            resourceTypes: resourceTypes, 
            telemetryConfigurationState: telemetryConfigurationState
        )
        return try await self.listResourceTelemetry(input, logger: logger)
    }

    ///  Returns a list of telemetry configurations for AWS resources supported by telemetry config in the organization.
    @Sendable
    @inlinable
    public func listResourceTelemetryForOrganization(_ input: ListResourceTelemetryForOrganizationInput, logger: Logger = AWSClient.loggingDisabled) async throws -> ListResourceTelemetryForOrganizationOutput {
        try await self.client.execute(
            operation: "ListResourceTelemetryForOrganization", 
            path: "/ListResourceTelemetryForOrganization", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    ///  Returns a list of telemetry configurations for AWS resources supported by telemetry config in the organization.
    ///
    /// Parameters:
    ///   - accountIdentifiers:  A list of AWS account IDs used to filter the resources to those associated with the specified accounts.
    ///   - maxResults:  A number field used to limit the number of results within the returned list.
    ///   - nextToken:  The token for the next set of items to return. A previous call provides this token.
    ///   - resourceIdentifierPrefix:  A string used to filter resources in the organization which have a ResourceIdentifier starting with the ResourceIdentifierPrefix.
    ///   - resourceTags:  A key-value pair to filter resources in the organization based on tags associated with the resource. Fore more information about tags, see What are tags?
    ///   - resourceTypes:  A list of resource types used to filter resources in the organization. If this parameter is provided, the resources will be returned in the same order used in the request.
    ///   - telemetryConfigurationState:  A key-value pair to filter resources in the organization based on the telemetry type and the state of the telemetry configuration. The key is the telemetry type and the value is the state.
    ///   - logger: Logger use during operation
    @inlinable
    public func listResourceTelemetryForOrganization(
        accountIdentifiers: [String]? = nil,
        maxResults: Int? = nil,
        nextToken: String? = nil,
        resourceIdentifierPrefix: String? = nil,
        resourceTags: [String: String]? = nil,
        resourceTypes: [ResourceType]? = nil,
        telemetryConfigurationState: [TelemetryType: TelemetryState]? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> ListResourceTelemetryForOrganizationOutput {
        let input = ListResourceTelemetryForOrganizationInput(
            accountIdentifiers: accountIdentifiers, 
            maxResults: maxResults, 
            nextToken: nextToken, 
            resourceIdentifierPrefix: resourceIdentifierPrefix, 
            resourceTags: resourceTags, 
            resourceTypes: resourceTypes, 
            telemetryConfigurationState: telemetryConfigurationState
        )
        return try await self.listResourceTelemetryForOrganization(input, logger: logger)
    }

    ///  This action begins onboarding onboarding the caller AWS account to the telemetry config feature.
    @Sendable
    @inlinable
    public func startTelemetryEvaluation(logger: Logger = AWSClient.loggingDisabled) async throws {
        try await self.client.execute(
            operation: "StartTelemetryEvaluation", 
            path: "/StartTelemetryEvaluation", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            logger: logger
        )
    }

    ///  This actions begins onboarding the organization and all member accounts to the telemetry config feature.
    @Sendable
    @inlinable
    public func startTelemetryEvaluationForOrganization(logger: Logger = AWSClient.loggingDisabled) async throws {
        try await self.client.execute(
            operation: "StartTelemetryEvaluationForOrganization", 
            path: "/StartTelemetryEvaluationForOrganization", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            logger: logger
        )
    }

    ///  This action begins offboarding the caller AWS account from the telemetry config feature.
    @Sendable
    @inlinable
    public func stopTelemetryEvaluation(logger: Logger = AWSClient.loggingDisabled) async throws {
        try await self.client.execute(
            operation: "StopTelemetryEvaluation", 
            path: "/StopTelemetryEvaluation", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            logger: logger
        )
    }

    ///  This action offboards the Organization of the caller AWS account from thef telemetry config feature.
    @Sendable
    @inlinable
    public func stopTelemetryEvaluationForOrganization(logger: Logger = AWSClient.loggingDisabled) async throws {
        try await self.client.execute(
            operation: "StopTelemetryEvaluationForOrganization", 
            path: "/StopTelemetryEvaluationForOrganization", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            logger: logger
        )
    }
}

extension ObservabilityAdmin {
    /// Initializer required by `AWSService.with(middlewares:timeout:byteBufferAllocator:options)`. You are not able to use this initializer directly as there are not public
    /// initializers for `AWSServiceConfig.Patch`. Please use `AWSService.with(middlewares:timeout:byteBufferAllocator:options)` instead.
    public init(from: ObservabilityAdmin, patch: AWSServiceConfig.Patch) {
        self.client = from.client
        self.config = from.config.with(patch: patch)
    }
}

// MARK: Paginators

@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
extension ObservabilityAdmin {
    /// Return PaginatorSequence for operation ``listResourceTelemetry(_:logger:)``.
    ///
    /// - Parameters:
    ///   - input: Input for operation
    ///   - logger: Logger used for logging
    @inlinable
    public func listResourceTelemetryPaginator(
        _ input: ListResourceTelemetryInput,
        logger: Logger = AWSClient.loggingDisabled
    ) -> AWSClient.PaginatorSequence<ListResourceTelemetryInput, ListResourceTelemetryOutput> {
        return .init(
            input: input,
            command: self.listResourceTelemetry,
            inputKey: \ListResourceTelemetryInput.nextToken,
            outputKey: \ListResourceTelemetryOutput.nextToken,
            logger: logger
        )
    }
    /// Return PaginatorSequence for operation ``listResourceTelemetry(_:logger:)``.
    ///
    /// - Parameters:
    ///   - maxResults:  A number field used to limit the number of results within the returned list.
    ///   - resourceIdentifierPrefix:  A string used to filter resources which have a ResourceIdentifier starting with the ResourceIdentifierPrefix.
    ///   - resourceTags:  A key-value pair to filter resources based on tags associated with the resource. For more information about tags, see What are tags?
    ///   - resourceTypes:  A list of resource types used to filter resources supported by telemetry config. If this parameter is provided, the resources will be returned in the same order used in the request.
    ///   - telemetryConfigurationState:  A key-value pair to filter resources based on the telemetry type and the state of the telemetry configuration. The key is the telemetry type and the value is the state.
    ///   - logger: Logger used for logging
    @inlinable
    public func listResourceTelemetryPaginator(
        maxResults: Int? = nil,
        resourceIdentifierPrefix: String? = nil,
        resourceTags: [String: String]? = nil,
        resourceTypes: [ResourceType]? = nil,
        telemetryConfigurationState: [TelemetryType: TelemetryState]? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) -> AWSClient.PaginatorSequence<ListResourceTelemetryInput, ListResourceTelemetryOutput> {
        let input = ListResourceTelemetryInput(
            maxResults: maxResults, 
            resourceIdentifierPrefix: resourceIdentifierPrefix, 
            resourceTags: resourceTags, 
            resourceTypes: resourceTypes, 
            telemetryConfigurationState: telemetryConfigurationState
        )
        return self.listResourceTelemetryPaginator(input, logger: logger)
    }

    /// Return PaginatorSequence for operation ``listResourceTelemetryForOrganization(_:logger:)``.
    ///
    /// - Parameters:
    ///   - input: Input for operation
    ///   - logger: Logger used for logging
    @inlinable
    public func listResourceTelemetryForOrganizationPaginator(
        _ input: ListResourceTelemetryForOrganizationInput,
        logger: Logger = AWSClient.loggingDisabled
    ) -> AWSClient.PaginatorSequence<ListResourceTelemetryForOrganizationInput, ListResourceTelemetryForOrganizationOutput> {
        return .init(
            input: input,
            command: self.listResourceTelemetryForOrganization,
            inputKey: \ListResourceTelemetryForOrganizationInput.nextToken,
            outputKey: \ListResourceTelemetryForOrganizationOutput.nextToken,
            logger: logger
        )
    }
    /// Return PaginatorSequence for operation ``listResourceTelemetryForOrganization(_:logger:)``.
    ///
    /// - Parameters:
    ///   - accountIdentifiers:  A list of AWS account IDs used to filter the resources to those associated with the specified accounts.
    ///   - maxResults:  A number field used to limit the number of results within the returned list.
    ///   - resourceIdentifierPrefix:  A string used to filter resources in the organization which have a ResourceIdentifier starting with the ResourceIdentifierPrefix.
    ///   - resourceTags:  A key-value pair to filter resources in the organization based on tags associated with the resource. Fore more information about tags, see What are tags?
    ///   - resourceTypes:  A list of resource types used to filter resources in the organization. If this parameter is provided, the resources will be returned in the same order used in the request.
    ///   - telemetryConfigurationState:  A key-value pair to filter resources in the organization based on the telemetry type and the state of the telemetry configuration. The key is the telemetry type and the value is the state.
    ///   - logger: Logger used for logging
    @inlinable
    public func listResourceTelemetryForOrganizationPaginator(
        accountIdentifiers: [String]? = nil,
        maxResults: Int? = nil,
        resourceIdentifierPrefix: String? = nil,
        resourceTags: [String: String]? = nil,
        resourceTypes: [ResourceType]? = nil,
        telemetryConfigurationState: [TelemetryType: TelemetryState]? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) -> AWSClient.PaginatorSequence<ListResourceTelemetryForOrganizationInput, ListResourceTelemetryForOrganizationOutput> {
        let input = ListResourceTelemetryForOrganizationInput(
            accountIdentifiers: accountIdentifiers, 
            maxResults: maxResults, 
            resourceIdentifierPrefix: resourceIdentifierPrefix, 
            resourceTags: resourceTags, 
            resourceTypes: resourceTypes, 
            telemetryConfigurationState: telemetryConfigurationState
        )
        return self.listResourceTelemetryForOrganizationPaginator(input, logger: logger)
    }
}

extension ObservabilityAdmin.ListResourceTelemetryForOrganizationInput: AWSPaginateToken {
    @inlinable
    public func usingPaginationToken(_ token: String) -> ObservabilityAdmin.ListResourceTelemetryForOrganizationInput {
        return .init(
            accountIdentifiers: self.accountIdentifiers,
            maxResults: self.maxResults,
            nextToken: token,
            resourceIdentifierPrefix: self.resourceIdentifierPrefix,
            resourceTags: self.resourceTags,
            resourceTypes: self.resourceTypes,
            telemetryConfigurationState: self.telemetryConfigurationState
        )
    }
}

extension ObservabilityAdmin.ListResourceTelemetryInput: AWSPaginateToken {
    @inlinable
    public func usingPaginationToken(_ token: String) -> ObservabilityAdmin.ListResourceTelemetryInput {
        return .init(
            maxResults: self.maxResults,
            nextToken: token,
            resourceIdentifierPrefix: self.resourceIdentifierPrefix,
            resourceTags: self.resourceTags,
            resourceTypes: self.resourceTypes,
            telemetryConfigurationState: self.telemetryConfigurationState
        )
    }
}
